import { defineStore } from 'pinia'
import { ref } from 'vue'

export const errorsStore = defineStore('errors', () => {
  
  const initedErrors = ref(false)
  const errorList = ref([])

  if (!initedErrors.value) {

    errorList.value = [];
    initedErrors.value = true
  }

  const add = (item) => {
    if (!errorList.value.includes(item)) {
      let q = errorList.value;
      q.push(item)
      errorList.value = q;
      return true
    }else{
      return false
    }
  }

  const init = () => {
    initedErrors.value = true
  }
 
  return {errorList,init,add}
})
